def searchMatrix(matrix, target):
    """
    :type matrix: List[List[int]]
    :type target: int
    :rtype: bool
    """
    if not matrix:
        return False
    row = len(matrix)
    col = len(matrix[0])
    left, right = 0, row * col - 1
    while left <= right:
        mid = left + (right - left) // 2
        element = matrix[mid // col][mid % col]
        if element == target:
            return True
        elif element > target:
            right = mid - 1
        else:
            left = mid + 1
    return False


matrix = [[1, 3, 5, 7], [10, 11, 16, 20], [23, 30, 34, 60]]
target = 5
print(searchMatrix(matrix, target))
